package clientApp;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import clientApp.utils.Map_Editor_Container;

import game.mapEditor.DrawFunctions;
import game.mechanics.Item;
import game.units.Monster;

/**
 *
 * @author Gabriel
 */
@SuppressWarnings("serial")
public class MapEditor extends javax.swing.JPanel {

	private static final long serialVersionUID = 1L;
	Map<Integer, Item> itensMap = Item.getItems();
	List<String> mosterNameList = new ArrayList<String>();
	
	public DrawFunctions funct;
	/** Creates new form GameMenu */
    public MapEditor(String size) {
        initComponents(size);
        refreshMonsterList();
        refreshItemList();
    }
    
    

	private void refreshItemList() {
    	jLItems.setModel(new javax.swing.AbstractListModel() {
			Map<Integer, Item> itens = itensMap;
            public int getSize() { return itens.size(); }
            public Object getElementAt(int i) { return itens.get(i+1).getName(); }
        });		
	}



	private void refreshMonsterList() {
		Map<String, Monster> monsterMap = Monster.getMonsters();
		mosterNameList.clear();
		for (String name : monsterMap.keySet())
			mosterNameList.add(name);
		
		jLMonster.setModel(new javax.swing.AbstractListModel() {
			List<String> monsters = mosterNameList;
            public int getSize() { return monsters.size(); }
            public Object getElementAt(int i) { return this.monsters.get(i); }
        });
	}



	/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     * @param size 
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents(String size) {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jTPTools = new javax.swing.JTabbedPane();
        jPTools1 = new javax.swing.JPanel();
        jBWall = new javax.swing.JButton();
        jBRemove = new javax.swing.JButton();
        jBLine = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jBSquare = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jCBGround = new javax.swing.JComboBox();
        jBSelect = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jTFMapName = new javax.swing.JTextField();
        jBSave = new javax.swing.JButton();
        jBLoad = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jBPallet = new javax.swing.JButton();
        jPTools2 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jLMonster = new javax.swing.JList();
        jBSelectMonster = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jLItems = new javax.swing.JList();
        jBSelectItem = new javax.swing.JButton();
        jPTools3 = new javax.swing.JPanel();
        jBBattleEvent = new javax.swing.JButton();
        jBStopEvent = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTFMapToChange = new javax.swing.JTextField();
        jTFXpos = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jTFYpos = new javax.swing.JTextField();
        jBChangeMap = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jPExibition = new Map_Editor_Container(size);
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setBackground(new java.awt.Color(153, 153, 153));

        jPanel1.setBackground(new java.awt.Color(0, 0, 102));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 28));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("MapEditor");

        jTPTools.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 1, true));

        jPTools1.setBackground(new java.awt.Color(0, 0, 102));

        jBWall.setText("Wall/Door");
        jBWall.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBWallActionPerformed(evt);
            }
        });

        jBRemove.setText("Remove");
        jBRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBRemoveActionPerformed(evt);
            }
        });

        jBLine.setText("Line");
        jBLine.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLineActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Paint Tool");

        jBSquare.setText("Square");
        jBSquare.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSquareActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Ground Tool");

        jCBGround.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Grass", "Cave", "Stone", "Sea" }));
        jCBGround.setActionCommand("");

        jBSelect.setText("Select");
        jBSelect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSelectActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Save Map | Load Map");

        jBSave.setText("Save");
        jBSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSaveActionPerformed(evt);
            }
        });

        jBLoad.setText("Load");
        jBLoad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLoadActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Color Pallet");

        jBPallet.setText("Open");
        jBPallet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBPalletActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPTools1Layout = new javax.swing.GroupLayout(jPTools1);
        jPTools1.setLayout(jPTools1Layout);
        jPTools1Layout.setHorizontalGroup(
            jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPTools1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPTools1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addContainerGap(91, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPTools1Layout.createSequentialGroup()
                        .addGroup(jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jBPallet, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                            .addComponent(jCBGround, javax.swing.GroupLayout.Alignment.LEADING, 0, 170, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jLabel5)
                                .addGroup(jPTools1Layout.createSequentialGroup()
                                    .addComponent(jBRemove)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jBWall))
                                .addGroup(jPTools1Layout.createSequentialGroup()
                                    .addComponent(jBLine)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jBSquare)))
                            .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jBSelect, javax.swing.GroupLayout.Alignment.LEADING))
                        .addContainerGap())
                    .addGroup(jPTools1Layout.createSequentialGroup()
                        .addGroup(jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPTools1Layout.createSequentialGroup()
                                .addComponent(jBSave, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                                .addComponent(jBLoad, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jTFMapName, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                            .addComponent(jLabel8))
                        .addGap(8, 8, 8))))
        );

        jPTools1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jBLine, jBRemove, jBSquare, jBWall});

        jPTools1Layout.setVerticalGroup(
            jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPTools1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBSquare)
                    .addComponent(jBLine))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBRemove)
                    .addComponent(jBWall))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCBGround, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(7, 7, 7)
                .addComponent(jBSelect)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBPallet)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTFMapName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPTools1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBSave)
                    .addComponent(jBLoad))
                .addContainerGap(132, Short.MAX_VALUE))
        );

        jTPTools.addTab("Tools", jPTools1);

        jPTools2.setBackground(new java.awt.Color(0, 0, 102));

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel10.setForeground(new java.awt.Color(255, 255, 255));
        jLabel10.setText("Monster Tool");

        jLMonster.setModel(new javax.swing.AbstractListModel() {
			private static final long serialVersionUID = 1L;
			String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(jLMonster);

        jBSelectMonster.setText("Select");
        jBSelectMonster.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSelectMonsterActionPerformed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("Item Tool");

        ;
        jScrollPane2.setViewportView(jLItems);

        jBSelectItem.setText("Select");
        jBSelectItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSelectItemActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPTools2Layout = new javax.swing.GroupLayout(jPTools2);
        jPTools2.setLayout(jPTools2Layout);
        jPTools2Layout.setHorizontalGroup(
            jPTools2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPTools2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPTools2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(jLabel10)
                    .addComponent(jBSelectMonster)
                    .addComponent(jLabel11)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(jBSelectItem))
                .addContainerGap())
        );
        jPTools2Layout.setVerticalGroup(
            jPTools2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPTools2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBSelectMonster)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBSelectItem)
                .addContainerGap(153, Short.MAX_VALUE))
        );

        jTPTools.addTab("Units/Items", jPTools2);

        jPTools3.setBackground(new java.awt.Color(0, 0, 102));

        //TODO daijobu, we do it all the time!
        jBBattleEvent.setText("Create Battle Event");
        jBBattleEvent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jBBattleTriggerActionPerformed(evt);
            }
        });

        jBStopEvent.setText("Create Stop Event");
        jBStopEvent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jBStopEventActionPerformed(evt);
            }
        });
        

        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Change Map Event:");

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Map Name:");

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("X pos:");

        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("Y pos:");

        jBChangeMap.setText("Create Change Map Event");
        jBChangeMap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBChangeMapActionPerformed(evt);
            }
        });

        jLabel12.setForeground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("Battle Event:");

        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("Stop Event:");

        javax.swing.GroupLayout jPTools3Layout = new javax.swing.GroupLayout(jPTools3);
        jPTools3.setLayout(jPTools3Layout);
        jPTools3Layout.setHorizontalGroup(
            jPTools3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPTools3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPTools3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jBBattleEvent, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jBStopEvent, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(jLabel2)
                    .addComponent(jBChangeMap, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addGroup(jPTools3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPTools3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPTools3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTFXpos)
                            .addComponent(jTFYpos)
                            .addComponent(jTFMapToChange, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(15, 15, 15)))
                .addContainerGap())
        );
        jPTools3Layout.setVerticalGroup(
            jPTools3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPTools3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBBattleEvent)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBStopEvent)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPTools3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTFMapToChange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPTools3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addComponent(jTFXpos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPTools3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTFYpos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBChangeMap)
                .addContainerGap(215, Short.MAX_VALUE))
        );

        jTPTools.addTab("Events", jPTools3);

        jPExibition.setBackground(new java.awt.Color(0, 0, 0));
        jPExibition.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        
        jPExibition.panels.show(jPExibition, "MapToEdit");
        funct = jPExibition.editMap.getDrawFunctions();

//        javax.swing.GroupLayout jPExibitionLayout = new javax.swing.GroupLayout(jPExibition);
//        jPExibition.setLayout(jPExibitionLayout);
//        jPExibitionLayout.setHorizontalGroup(
//            jPExibitionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGap(0, 551, Short.MAX_VALUE)
//        );
//        jPExibitionLayout.setVerticalGroup(
//            jPExibitionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
//            .addGap(0, 507, Short.MAX_VALUE)
//        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 633, Short.MAX_VALUE))
                    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 760, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jTPTools, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPExibition, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jTPTools, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
                        .addContainerGap())
                    .addComponent(jPExibition, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        jMenu1.setText("Main Menu");
        jMenuBar1.add(jMenu1);

        jMenu3.setText("Character");

        jMenuItem1.setText("jMenuItem1");
        jMenu3.add(jMenuItem1);

        jMenuBar1.add(jMenu3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jBLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLoadActionPerformed
        funct.load(jTFMapName.getText());        
    }//GEN-LAST:event_jBLoadActionPerformed

    private void jBSquareActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSquareActionPerformed
        funct.setTool(DrawFunctions.RECT);        
    }//GEN-LAST:event_jBSquareActionPerformed

    private void jBLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLineActionPerformed
        funct.setTool(DrawFunctions.LINE);   
    }//GEN-LAST:event_jBLineActionPerformed

    private void jBRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBRemoveActionPerformed
    	funct.setTool(DrawFunctions.REMOVE);
    }//GEN-LAST:event_jBRemoveActionPerformed

    private void jBWallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBWallActionPerformed
        funct.setTool(DrawFunctions.WALL);     
    }//GEN-LAST:event_jBWallActionPerformed

    private void jBPalletActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBPalletActionPerformed
    	ColorPallet cp = new ColorPallet(jPExibition);
    	jPExibition.cp = cp;
    	jPExibition.panels.show(jPExibition, "ColorPallet");
    }//GEN-LAST:event_jBPalletActionPerformed

    private void jBSelectMonsterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSelectMonsterActionPerformed
//    	Monster m = monsterMap.get(jLMonster.getSelectedValue());
//    	.getSelectedIndex());
    	funct.setTool(DrawFunctions.UNIT);
    	funct.selectMonster((String) jLMonster.getSelectedValue());
    }//GEN-LAST:event_jBSelectMonsterActionPerformed

    private void jBSelectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSelectItemActionPerformed
    	Item i = itensMap.get(jLItems.getSelectedIndex() + 1);
    	funct.setTool(DrawFunctions.PLACE_ITEM);
    	funct.itemToPlace(i);
    }//GEN-LAST:event_jBSelectItemActionPerformed

    private void jBSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSelectActionPerformed
        funct.setPattern(jCBGround.getSelectedIndex());    
        funct.setTool(DrawFunctions.TILEFILL);  
    }//GEN-LAST:event_jBSelectActionPerformed

    private void jBChangeMapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBChangeMapActionPerformed
        funct.setTool(DrawFunctions.CHANGE_MAP);      
        funct.setChangeMapAttr(jTFMapToChange.getText(), jTFXpos.getText(), jTFYpos.getText());  
    }//GEN-LAST:event_jBChangeMapActionPerformed

    private void jBSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSaveActionPerformed
        funct.save(jTFMapName.getText());
    }//GEN-LAST:event_jBSaveActionPerformed

    private void jBStopEventActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLoadActionPerformed
    	funct.setTool(DrawFunctions.STOP_EVENT);
    }//GEN-LAST:event_jBLoadActionPerformed

    private void jBBattleTriggerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLoadActionPerformed
    	funct.setTool(DrawFunctions.BATTLE_TRIGGER);
    }//GEN-LAST:event_jBLoadActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBBattleEvent;
    private javax.swing.JButton jBChangeMap;
    private javax.swing.JButton jBLine;
    private javax.swing.JButton jBLoad;
    private javax.swing.JButton jBPallet;
    private javax.swing.JButton jBRemove;
    private javax.swing.JButton jBSave;
    private javax.swing.JButton jBSelect;
    private javax.swing.JButton jBSelectItem;
    private javax.swing.JButton jBSelectMonster;
    private javax.swing.JButton jBSquare;
    private javax.swing.JButton jBStopEvent;
    private javax.swing.JButton jBWall;
    private javax.swing.JComboBox jCBGround;
    private javax.swing.JList jLItems;
    private javax.swing.JList jLMonster;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    public Map_Editor_Container jPExibition;
    private javax.swing.JPanel jPTools1;
    private javax.swing.JPanel jPTools2;
    private javax.swing.JPanel jPTools3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextField jTFMapName;
    private javax.swing.JTextField jTFMapToChange;
    private javax.swing.JTextField jTFXpos;
    private javax.swing.JTextField jTFYpos;
    private javax.swing.JTabbedPane jTPTools;
    // End of variables declaration//GEN-END:variables
}
